package com.freshcity.page.wait
{
	import com.freshcity.component.guide.GuideArrowManager;
	import com.freshcity.component.guide.GuideTipsManager;
	import com.freshcity.component.guide.LineBoxTips;
	import com.freshcity.core.BaseGuide;
	import com.freshcity.core.OpCodes;
	import com.freshcity.core.SoundTypeConst;
	import com.freshcity.graphics.RoomInfoWin;
	import com.freshcity.manager.EffectManager;
	import com.freshcity.manager.LayerManager;
	import com.freshcity.manager.support.MaskInfo;
	import com.freshcity.page.user.SelfHome;
	import com.greensock.TweenLite;
	import com.pblabs.debug.Logger;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	public class RoomListGuide extends BaseGuide
	{
		private var win:RoomInfoWin;
		private var layer:LayerManager;
		private var guideTip:GuideTipsManager;
		private var arrow:GuideArrowManager;
		private var home:RoomList;
		
		
		public function RoomListGuide(hostPage:RoomList)
		{
			this.home = hostPage;
			this.host = hostPage.group;
			this.win = hostPage.win;
			this.layer = host.layer;
			this.guideTip = host.guideTip;
			this.arrow = host.guideArrow;			
		}
		
		public function onGuideStep1():void
		{
			var position:Point = win.localToGlobal(new Point(201,78));
			var size:Point = new Point(55,25);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);			
			//var myfun:Function = function():void{GuideTipsManager.hideLineBoxTips();onGuideStep3()};
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips("这是正在沟通的人",size.x,size.y,onGuideStep3,2000,GuideTipsManager.Dir_TR);
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer.addChild(lt);			
		}
		
		private function onGuideStep3():void
		{
			var s:String = "这是正在等候的人";
			var position:Point = win.localToGlobal(new Point(249,78));
			var size:Point = new Point(100,25);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips(s,size.x,size.y,onGuideStep4,2000,GuideTipsManager.Dir_TR);
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer.addChild(lt);	
		}
		
		private function onGuideStep4():void
		{
			var s:String = "点击加入沟通队列";
			var position:Point = win.localToGlobal(new Point(290,120));
			var size:Point = new Point(60,25);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips(s,size.x,size.y,clear,0,GuideTipsManager.Dir_TR);
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer.addChild(lt);		
		}
		
		public function onGuideStep5():void
		{
			var position:Point = new Point();
			var size:Point = new Point();
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);
			
			GuideTipsManager.hideLineBoxTips();
			
			var loc4:DisplayObject = guideTip.getGuideTips("...");
			loc4.alpha = 0;
			loc4.x = (win.stage.stageWidth - loc4.width) / 2;
			loc4.y = (win.stage.stageHeight - loc4.height) / 2;			
			LayerManager.msgTipLayer.addChild(loc4);			
			TweenLite.to(loc4,0.2,{alpha:1,onComplete:onGuideStep7});
		}
		
		private function onGuideStep5_1():void
		{
			var s:String = "现在到了等候的时刻,她需要你的运气和耐心！每次交流开始前都会有提示音响起,可以点击这里测试。";
			var loc:DisplayObject = guideTip.getGuideTips(s,onGuideStep5_2,1);			
		}		
		
		
		private function onGuideStep5_2():void
		{
			var s:String = "点击测试提示音";
			var position:Point = new Point(758,9);
			var size:Point = new Point(26,25);
			
			var testPanel:Sprite = new Sprite();
			testPanel.graphics.beginFill(0,0.01);
			testPanel.graphics.drawRect(0,0,size.x,size.y);
			testPanel.graphics.endFill();
			
			testPanel.x = position.x;
			testPanel.y = position.y;
			testPanel.width = size.x;
			testPanel.height = size.y;
			win.stage.addChild(testPanel);
			
			
			var myfun:Function = function(e:Event):void{
				host.soundManager.playSound(SoundTypeConst.ComeIn,true);
				win.stage.removeChild(testPanel);
				TweenLite.delayedCall(2,onGuideStep6);
			}				
			testPanel.addEventListener(MouseEvent.CLICK,myfun);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);
		
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips(s,size.x,size.y,null,0,GuideTipsManager.Dir_TR);
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer..addChild(lt);
		}		
		
		private function onGuideStep6():void
		{
			var s:String = "听到像门铃一样的提示音了吗？ 如果没有，请检查你电脑的声音设置。";
			var loc:DisplayObject = guideTip.getGuideTips(s,onGuideStep7,1);			
		}		
		
		private function onGuideStep7():void
		{
			var s:String = "缘分需要耐心和运气。你现在不得不在这里等候,直到有缘人出现...";
			var loc:DisplayObject = guideTip.getGuideTips(s);	
			
			TweenLite.to(loc,1,{alpha:0,y:480,onComplete:clear,delay:5});
			this.setCallBack(function():void{});
		}

		
		public function onGuideStep9(callback:Function):void
		{
			var position:Point = win.localToGlobal(new Point(301,120));
			var size:Point = new Point(55,25);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);			
			//var myfun:Function = function():void{GuideTipsManager.hideLineBoxTips();onGuideStep3()};
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips("选择沟通对象",size.x,size.y,onGuideStep10,0,GuideTipsManager.Dir_TR);
			this.setCallBack(callback);
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer.addChild(lt);	
		}
		
		public function onGuideStep10():void
		{
			var position:Point = win.localToGlobal(new Point(321,320));
			var size:Point = new Point(55,25);
			
			var loc1:*=new MaskInfo(position,size);
			EffectManager.addUIMask([loc1],0);			
			//var myfun:Function = function():void{GuideTipsManager.hideLineBoxTips();onGuideStep3()};
			var lt:LineBoxTips = GuideTipsManager.getLineBoxTips("计时结束后点击确认",size.x,size.y,clear,3000,GuideTipsManager.Dir_TR);
			
			lt.x = position.x + size.x/2;
			lt.y = position.y + size.y;
			LayerManager.msgTipLayer.addChild(lt);
		}		
	}
}